package com.system.controller;

import com.system.po.sep.*;
import com.system.service.EmerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;


@Api(description = "应急预案")
@RequestMapping("eme")
@Controller
@ResponseBody
public class EmerController {

       @Autowired
       private EmerService emerService;

       @RequestMapping("/findall/{id}")
       @ApiOperation(value = "树状结构", notes = "findall" , httpMethod = "GET")

       public List<Sep> findall(Integer id){
          List<Sep> seps=emerService.selectfindall(id);
          return seps;
       }

    @ApiOperation(value = "增加兄弟节点")
    @PostMapping("/addsiblingnode")

    public Boolean addsiblingnode(@RequestBody Sep_One sep_one){
        Boolean siblingnode = emerService.addsiblingnode(sep_one);
        return siblingnode;
    }
    @ApiOperation(value = "增加子节点")
    @PostMapping("/addChildnode/{id}")

    public Boolean addChildnode(@RequestBody Sep_Two sep_two, Integer id){
        Boolean Childnode = emerService.addChildnode(id,sep_two);
        return Childnode;
    }

    @ApiOperation(value = "编辑兄弟节点当前内容")
    @PutMapping("/editcurrentcontent")

    public Boolean editcurrentcontent(@RequestBody Sep_One_Edit sep_one_edit){
        Boolean Childnode = emerService.editcurrentcontent(sep_one_edit);
        return Childnode;
    }
    @ApiOperation(value = "编辑子节点当前内容")
    @PutMapping("/editchildcontent")

    public Boolean editchildcontent(@RequestBody Sep_Two_Edit sep_two_edit){
        Boolean childcontent = emerService.editchildcontent(sep_two_edit);
        return childcontent;
    }

    @ApiOperation(value = "删除兄弟节点")
    @DeleteMapping("/deletenode")
    public Boolean deletenode(Integer id){
        Boolean deletenode = emerService.deletenode(id);
        return deletenode;
    }

    @ApiOperation(value = "删除子节点")
    @DeleteMapping("/deletechildnode/{id}")
    public Boolean deletechildnode(Integer id){
        Boolean deletechildnode = emerService.deletechildnode(id);
        return deletechildnode;
    }
    @ApiOperation(value = "查找兄弟节点")
    @GetMapping("/lookupcurrentcontent/{id}")
    public Sep_One lookupcurrentcontent(Integer id){
        Sep_One lookupcurrentcontent = emerService.lookupcurrentcontent(id);
        return lookupcurrentcontent;
    }

    @ApiOperation(value = "查找子节点")
    @GetMapping("/lookupchildnode/{id}")
    public Sep_Two lookupchildnode(Integer id){
        Sep_Two lookupchildnode = emerService.lookupchildnode(id);
        return lookupchildnode;
    }

}
